<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="打印模板" prop="modelFileName">
          <hey-select v-model="formModel.modelFileName" filterable clearable clcd="print_model_cd" />
        </el-form-item>
        <el-form-item class="no-warn-item" label="打印机名:" prop="printerName">
          <el-input
            v-model="formModel.printerName"
            placeholder="打印机名"
            class="filter-item filter-200"
            clearable
          />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button v-if="hasPermission('print_config_select')" type="primary" plain @click="queryList(false)">查询</el-button>
            <el-button v-if="hasPermission('print_config_add')" type="primary" plain @click="handleAdd">新增</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :columns="columns" :is-select="false">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="160"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span v-if="hasPermission('print_config_edit')" class="hey_tools_btn" @click="handleEdit(row)">编辑</span>
            <span v-if="hasPermission('print_config_del')" class="hey_tools_btn" @click="handleDelete(row)">删除</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>
    <el-dialog
      v-if="dialogVisible"
      v-dialogDrag
      :close-on-click-modal="false"
      title="打印模板配置信息"
      :visible.sync="dialogVisible"
      width="80%"
    >
      <print-config-mnt :page-type="operType" :edit-data="editData" @mntSuc="queryList" />
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'PrintConfigList',
  components: {
    PrintConfigMnt: () => import('./print-config-mnt')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      operType: '',
      editData: {},
      formModel: {
        isDelete: '0',
        status: '',
        modelFileName: '',
        printerName: ''
      },
      columns: [
        { title: '打印模板代码', key: 'modelFileName' },
        { title: '打印模板名称', key: 'modelFileName', clcd: 'print_model_cd' },
        { title: '打印机名', key: 'printerName' },
        { title: '打印份数', key: 'printNum' },
        { title: '服务状态', key: 'status', clcd: 'is_effective_cd' },
        { title: '创建时间', key: 'createTime' },
        { title: '创建人', key: 'createUsername' },
        { title: '最后修改时间', key: 'lastUpdateTime' },
        { title: '最后修改人', key: 'lastUpdateUsername' }
      ]
    }
  },
  computed: {},
  mounted() {

  },
  methods: {
    queryList() {
      this.$refs.table.query('/printModelConfig/queryPrintModelConfig', this.formModel, '', false)
    },
    handleAdd() {
      this.operType = 'add'
      this.dialogVisible = true
    },
    handleEdit(row) {
      this.dialogVisible = true
      this.operType = 'edit'
      this.editData = row || {}
    },
    handleDelete(row) {
      this.$sure('确认删除？', _ => {
        this.post('/printModelConfig/maintainPrintModelConfig', { rcrdId: row.rcrdId, operateType: '03' }).then(_ => {
          this.$info('删除成功', this.queryList)
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
